package com.microinvest.dao;
import com.microinvest.entity.Users;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

@Mapper
public interface UserMapper {
    //用户注册
//    @Insert("insert into users(username,password,email)" +
//            "values(#{userName},#{password},#{email})")
    void registerUsers(Users users);

    //通过用户名称返回userId
    int getUserIdFromUserName(String userName);

    //用户注册stockSummary表
    void registerUserStockSummary(int userId);
    //用户名或邮箱是否存在
//    @Select("SELECT COUNT(*) > 0 FROM users WHERE username = #{userName} OR email = #{email}")
    Boolean existsByUsernameOrEmail(@Param("userName") String userName, @Param("email") String email);

    //比对用户名对应的密码哈希值是否正确
    Boolean comparePassword(String userName, String encryptedPassword);

    //获取用户数据
    Users usersInfo(String userName,String email);

    //修改密码
    void updateWithOldPwd(String newPassword);
}
